<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title><?php echo ($title); ?></title>
    <link rel="stylesheet" type="text/css" href="/Public/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/style.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/bootstrapValidator.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/mregister.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/mreg.css" />
    <script type="text/javascript" src="/Public/js/Jquery/jquery-1.js"></script>
    <script type="text/javascript" src="/Public/js/bootstrapValidator.js"></script>
    <script language="JavaScript">
        /**
         * 手机号合法验证
         */
        function get_mobile_phone(){
            //var email=document.getElementById('username').value;
            //var reg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var mobile=document.getElementById('phone').value;
            var reg=/^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var res=mobile.match(reg);
            if(res){
                $.post("<?php echo U('/phoneCheck');?>",{phone:mobile},function (msg){
                    if(msg=="0"){
                        document.getElementById('errorImg').src="/Public/images/tick.png";
                        messages.innerHTML="手机号可用";
                        result.style.display="block";
                        $(" #result").fadeOut(2000);
                    }else if(msg=="1"){
                        document.getElementById('errorImg').src="/Public/images/error.jpg";
                        messages.innerHTML="该手机号已被注册";
                        result.style.display="block";
                        document.getElementById('phone').value="";
                        document.getElementById('phone').focus();
                    }else{
                        alert(msg);
                    }
                });
            }else{
                document.getElementById('errorImg').src="/Public/images/error.jpg";
                messages.innerHTML="请填写正确的手机号格式";
                result.style.display="block";
                document.getElementById('phone').focus();
            }
        }

        /**
         * 密码一致验证
         */
        function checkPass(){
            var pwd=document.getElementById('password').value;
            var conPwd=document.getElementById('conPassword').value;
            var reg=/^[\@A-Za-z0-9\!\#\$\%\^\&\*\.\~]{6,18}$/;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var res=pwd.match(reg);
            if(res){
                if(pwd!=conPwd){
                    document.getElementById('errorImg').src="/Public/images/error.png";
                    messages.innerHTML="两次输入密码不一致";
                    result.style.display="block";
                    document.getElementById('conPassword').focus();
                }else{
                    if(result.style.display!="none"){
                        result.style.display="none";
                    }
                }
            }else{
                document.getElementById('errorImg').src="/Public/images/error.jpg";
                messages.innerHTML="密码长度不合法";
                result.style.display="block";
                document.getElementById('password').focus();
            }
        }

        /**
         * 注册验证
         */
        function mndregCheck(){
            //var email=document.getElementById('username').value;
            //var reg=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            var mobile=document.getElementById('phone').value;
            var password=document.getElementById('password').value;
            var conPassword=document.getElementById('conPassword').value;
            var verify=document.getElementById('verify').value;
            var reg=/^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/;
            var result=document.getElementById("result");
            var messages=document.getElementById("messages");
            var res=mobile.match(reg);
            if(res){
                $.post("<?php echo U('/mndregCheck');?>",{mobile:mobile,password:password,conPassword:conPassword,verify:verify},function(msg){
                    if(msg=="0"){
                        result.style.display="none";
                        if(result.style.display=="none"){
                            window.location.href="<?php echo U('/tips');?>";
                        }else{
                            document.getElementById('errorImg').src="/Public/images/error.jpg";
                            messages.innerHTML="错误信息未处理完成。";
                            result.style.display="block";
                        }
                    }else if(msg=="1"){
                        document.getElementById('errorImg').src="/Public/images/error.jpg";
                        messages.innerHTML="数据写入失败。";
                        result.style.display="block";
                    }else if(msg=="2"){
                        document.getElementById('errorImg').src="/Public/images/error.png";
                        messages.innerHTML="两次输入密码不一致。";
                        result.style.display="block";
                        document.getElementById('conPassword').focus();
                    }else if(msg=="3"){
                        document.getElementById('errorImg').src="/Public/images/error.png";
                        messages.innerHTML="验证码错误。";
                        result.style.display="block";
                        document.getElementById('verify').focus();
                    }else if(msg=="4"){
                        document.getElementById('errorImg').src="/Public/images/error.jpg";
                        messages.innerHTML="该手机号已经被注册。";
                        result.style.display="block";
                        document.getElementById('phone').focus();
                    }else if(msg=="5"){
                        document.getElementById('errorImg').src="/Public/images/error.jpg";
                        messages.innerHTML="请填写正确的手机号格式。";
                        result.style.display="block";
                        document.getElementById('phone').focus();
                    }else if(msg=="6"){
                        window.location.href="<?php echo U('/mstreg');?>";
                    }else if(msg=="7"){
                        alert("对不起！验证码已过期。");
                        window.location.href="<?php echo U('/mstreg');?>";
                    }else if(msg=="8"){
                        document.getElementById('errorImg').src="/Public/images/error.jpg";
                        messages.innerHTML="密码长度不合法。";
                        result.style.display="block";
                        document.getElementById('password').focus();
                    }else{
                        alert(msg);
                    }
                });
            }else{
                document.getElementById('errorImg').src="/Public/images/error.jpg";
                messages.innerHTML="请填写正确的手机号格式";
                result.style.display="block";
                document.getElementById('phone').focus();
            }
        }
    </script>
</head>
<body>
<!--------------------------------导航栏-------------------------------------->
<div id="nav">
    <div class="container">
        <div class="row" style="margin-top:0px;">
            <div class="col-lg-12" style="background-color: #ff2d4b;">
                <img src="/Public/images/LOGO2.png"  class="img-responsive" onclick="back(this)" style="cursor: pointer;"/>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function back(obj){
        obj.src=window.location.href="<?php echo U('/index');?>";
    }
</script>
    <div class="container">
        <div class="row" style="margin-top:20px;">
            <div class="col-lg-6">
                <img src="/Public/images/LOGO.png" class="img-responsive"/>
            </div>
        </div>

        <div class="row" style="margin-top:20px;">
            <div class="col-lg-6">
                <img src="/Public/images/people.png" class="img-responsive"/>
            </div>
            <section>
                <div class="col-lg-6">
                    <form role="form" novalidate="novalidate" id="mregister-form" method="post">

                        <div id="mregister-title">
                        <span>
                            <div style="float: left;">///////////////////</div>
                            <label>注册</label>
                            <div style="float: right;">///////////////////</div>
                        </span>
                        </div>

                        <!--error tips-->
                        <!--error tips start-->
<div id="result">
    <img id="errorImg" src="/Public/images/error.jpg" alt="错误提示"/>
    <span id="messages"></span>
</div>
<!--error tips end-->

                        <div id="mregister-content" style="height: 250px;">
                            <!--<div class="form-group has-feedback">
                                <label for="email" class="col-sm-2 control-label">邮&nbsp;&nbsp;&nbsp;箱</label>
                                <input style="font-size: 16px;" type="text" data-bv-field="email" name="email" id="email" class="form-control col-sm-10" required="required" placeholder="请输入您的邮箱" maxlength="40"/>
                            </div>-->
                            <div class="form-group has-feedback">
                                <label for="phone" class="col-sm-2 control-label">手&nbsp;&nbsp;&nbsp;机</label>
                                <input style="font-size: 16px;" type="text" name="phone" id="phone" class="form-control col-sm-10" required="required" placeholder="请输入您的手机号码" maxlength="11" onblur="get_mobile_phone()"/>
                            </div>
                            <div class="form-group has-feedback">
                                <label for="password" class="col-sm-2 control-label">密&nbsp;&nbsp;&nbsp;码</label>
                                <input type="password" name="password" id="password" class="form-control col-sm-10"  required="required" placeholder="请输入您的密码" maxlength="20"  onKeyUp="pwStrength(this.value)" onBlur="pwStrength(this.value)"/>
                                <table border="1" cellspacing="0" cellpadding="1" bordercolor="#cccccc" height="23" style='display:inline;'>
                                    <tr align="center" bgcolor="#eeeeee">
                                        <td width="88px" id="strength_L">弱</td>
                                        <td width="88px" id="strength_M">中</td>
                                        <td width="88px" id="strength_H">强</td>
                                    </tr>
                                </table>
                            </div>
                            <div class="form-group has-feedback">
                                <label for="conPassword" class="col-sm-2 control-label">确认密码</label>
                                <input type="password"  name="conPassword" id="conPassword" class="form-control col-sm-10"  required="required" placeholder="请再次输入您的密码" maxlength="20" onblur="checkPass()"/>
                            </div>
                            <div class="form-group form-verify">
                                <label for="verify" class="col-sm-2 control-label">验&nbsp;证&nbsp;码</label>
                                <input type="text" name="verify" id="verify" class="form-control col-sm-10" required="required" maxlength="4"/>
                                <img src="<?php echo U('/verify');?>" alt="验证码" title="单击变换验证码" onclick="change(this)" style="cursor: pointer; width: 34%;height: 40px;float: left; border-radius: 6px;"/>
                            </div>
                        </div>

                        <div id="mregister-bottom">
                            <div class="form-group">
                                <div class="col-sm-offset-3 col-sm-10">
                                    <input type="button" onclick="mndregCheck()" class="btn btn-default btn-lg active" style="width: 230px; text-align: center;" value="同意以下协议并注册"/>
                                </div>
                            </div>
                            <div style="float: right; margin-right: 20px; padding-bottom: 20px;color: #afafaf; font-size: 20px;font-family: '微软雅黑,宋体';">
                                <a class="help-block" href="javascript:void(0)" style="color: #ff2d4b; text-decoration: underline; font-size: 16px;">&lt;&lt;用户协议&gt;&gt;</a>
                            </div>
                        </div>
                    </form>
                    <script type="text/javascript">
                        function change(obj) {
                            obj.src = "<?php echo U('/verify');?>?_=" + Math.random();
                        }
                        //CharMode函数
                        //测试某个字符是属于哪一类.
                        function CharMode(iN){
                            if (iN>=48 && iN <=57) //数字
                                return 1;
                            if (iN>=65 && iN <=90) //大写字母
                                return 2;
                            if (iN>=97 && iN <=122) //小写
                                return 4;
                            else
                                return 8; //特殊字符
                        }
                        //bitTotal函数
                        //计算出当前密码当中一共有多少种模式
                        function bitTotal(num){
                            modes=0;
                            for (i=0;i<4;i++){
                                if (num & 1) modes++;
                                num>>>=1;
                            }
                            return modes;
                        }
                        //checkStrong函数
                        //返回密码的强度级别
                        function checkStrong(sPW){
                            if (sPW.length<=4)
                                return 0; //密码太短
                            Modes=0;
                            for (i=0;i<sPW.length;i++){
//测试每一个字符的类别并统计一共有多少种模式.
                                Modes|=CharMode(sPW.charCodeAt(i));
                            }
                            return bitTotal(Modes);
                        }
                        //pwStrength函数
                        //当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色
                        function pwStrength(pwd){
                            O_color="#eeeeee";
                            L_color="#FF0000";
                            M_color="#FF9900";
                            H_color="#33CC00";
                            if (pwd==null||pwd==''){
                                Lcolor=Mcolor=Hcolor=O_color;
                            }
                            else{
                                S_level=checkStrong(pwd);
                                switch(S_level) {
                                    case 0:
                                        Lcolor=Mcolor=Hcolor=O_color;
                                    case 1:
                                        Lcolor=L_color;
                                        Mcolor=Hcolor=O_color;
                                        break;
                                    case 2:
                                        Lcolor=Mcolor=M_color;
                                        Hcolor=O_color;
                                        break;
                                    default:
                                        Lcolor=Mcolor=Hcolor=H_color;
                                }
                            }
                            document.getElementById("strength_L").style.background=Lcolor;
                            document.getElementById("strength_M").style.background=Mcolor;
                            document.getElementById("strength_H").style.background=Hcolor;
                            return;
                        }
                    </script>
                </div>
            </section>
            <script type="text/javascript">
                $(document).ready(function () {
                    // Generate a simple captcha
                    function randomNumber(min, max) {
                        return Math.floor(Math.random() * (max - min + 1) + min);
                    };
                    $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

                    $('#mregister-form').bootstrapValidator({
                        //        live: 'disabled',
                        message: '输入无效',
                        feedbackIcons: {
                            valid: 'glyphicon glyphicon-ok',
                            invalid: 'glyphicon glyphicon-remove',
                            validating: 'glyphicon glyphicon-refresh'
                        },
                        fields: {
                            /*email: {
                                validators: {
                                    emailAddress: {
                                        message: '邮箱地址不合法'
                                    }
                                }
                            },*/
                            phone:{
                                validators: {
                                    notEmpty: {
                                        message: '手机号不能为空'
                                    },
                                    regexp: {
                                        regexp: /^(13[0-9]|15[0|1|2|3|6|7|8|9]|18[0|2|3|5|6|7|8|9]|17[0])\d{8}$/,
                                        message: '手机号必须且由11位数字组成格式正确'
                                    }
                                }
                            },
                            verify:{
                                validators:{
                                    notEmpty:{
                                        message:'验证码不能为空'
                                    },
                                    regexp:{
                                        regexp:/^[A-Za-z0-9]{4}$/,
                                        message:'验证码必须由4位字符组成'
                                    }
                                }
                            }
                        }
                    });

                    // Validate the form manually
                    $('#validateBtn').click(function () {
                        $('#mregister-form').bootstrapValidator('validate');
                    });

                    $('#resetBtn').click(function () {
                        $('#mregister-form').data('bootstrapValidator').resetForm(true);
                    });
                });
            </script>
        </div>
    </div>
<!--	引入底部	-->
﻿<div id = "footer">
    <div>
        <a href = "#">关于我们</a> <a href = "#">联系客服</a> <a href = "#">招聘信息</a> <a href = "#">意见反馈</a> <a href = "#">版权投诉</a>
    </div>
    <div style = "color:#ffffff;">&copy;2015 深圳市妈妈好菜网络科技有限公司 版权所有 蜀ICP备14025970号-1</div>
</div>
</body>
</html>